package com.woniu.cq.medical.controller;


import com.woniu.cq.medical.common.Result;
import com.woniu.cq.medical.entity.Case;
import com.woniu.cq.medical.entity.Medicine;
import com.woniu.cq.medical.service.MedicineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2020-09-05
 */
@RestController
@RequestMapping("/medical/medicine")
@CrossOrigin("*")//解决跨域问题
@Slf4j
public class MedicineController {
    @Autowired
    private MedicineService medicineService;

    /**
     * 根据名字模糊查询药品
     * @return
     */
    @RequestMapping("selectMedicineLikeName")
    public Result selectMedicineLikeName(String MedicineName){
        List<Medicine> medicines = medicineService.selectMedicineLikeName(MedicineName);
        return Result.success(medicines);
    }

    /**
     * 根据药品名字和规格找出对应的药品
     * @param MedicineName
     * @param ProductFormat
     * @return
     */
    @RequestMapping("selectMedicineLikeNameAndProductFormat")
    public Result selectMedicineLikeNameAndProductFormat (String MedicineName,String ProductFormat){
        Medicine medicine = medicineService.selectMedicineLikeNameAndProductFormat(MedicineName, ProductFormat);
        return Result.success(medicine);
    }
}

